const express = require('express');
const router = express.Router();
const MenuController = require('../controllers/menu.controller');
const { authMiddleware } = require('../middlewares/auth.middleware');

// 创建菜单
router.post('/', authMiddleware, MenuController.createMenu);

// 获取所有菜单
router.get('/', authMiddleware, MenuController.getAllMenus);

// 获取菜单树 - 注意：这个路由必须在/:id路由之前
router.get('/tree', authMiddleware, MenuController.getMenuTree);

// 获取用户菜单 - 注意：这个路由必须在/:id路由之前
router.get('/user/menus', authMiddleware, MenuController.getUserMenus);

// 获取菜单详情
router.get('/:id', authMiddleware, MenuController.getMenuById);

// 更新菜单
router.put('/:id', authMiddleware, MenuController.updateMenu);

// 删除菜单
router.delete('/:id', authMiddleware, MenuController.deleteMenu);

module.exports = router; 